<?php
namespace Protocols;

use Workerman\Connection\TcpConnection;
 
class Worker
{
    public static $protocols = Frame::class;
    public static $conn = null;
    public static function __callStatic($name, $args)
    {
        switch ($name) {
            case 'input':
                //Worker 封包
                if (strlen($buffer) < 4) {
                    return 0;
                }
                self::$conn = unpack('Nln', $buffer);
                return call_user_func([static::$protocols,'input'], substr($args[0], 4), $args[1]);
            case 'decode':
                return call_user_func([static::$protocols,'decode'], substr($args[0], 4) );
            case 'encode':
                return pack('N', self::$conn ).call_user_func([static::$protocols,'encode'], $args[0] );
            default:
                return call_user_func_array([static::$protocols,$name], $args);
        }
    }
}
